import request from '@/utils/request'
import upload from '@/utils/upload'

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
	const data = {
		oldPassword,
		newPassword
	}
	return request({
		url: '/system/user/profile/updatePwd',
		method: 'put',
		params: data
	})
}

// 查询用户个人信息
export function getUserProfile() {
	return request({
		url: '/system/user/profile',
		method: 'get'
	})
}

// 修改用户个人信息
export function updateUserProfile(data) {
	return request({
		url: '/system/user/profile',
		method: 'put',
		data: data
	})
}

// 用户头像上传
export function uploadAvatar(data) {
	return upload({
		url: '/system/user/profile/avatar',
		name: data.name,
		filePath: data.filePath
	})
}

/**
 * 获取缴费信息
 * @param {Object} data
 */
export function getStudentRecordList(data) {
	return request({
		url: '/paymentRecord/getStudentRecordList',
	})
}

/**
 * 获取学生信息
 * @param {Object} data
 */
export function getStudentInfo(data) {
	return request({
		url: '/student/getStudentInfo',
	})
}

// 绑定微信
export function bindWechat(code) {
	return request({
		url: '/student/bindWechat?code=' + code,
		method: 'post',
		headers: {
			isToken: true
		},
	})
}

// 微信登录
export function wechatLogin(code) {
	return request({
		url: '/student/wechatLogin?code=' + code,
		method: 'post',
	})
}

// 获取/system/dict/data/type/sys_changetype


// 请假
export function leaveApply(data) {
	return request({
		url: '/leaveApply/launch',
		method: 'post',
		data
	})
}

// 请假列表
export function myApproveList(params) {
	return request({
		url: '/leaveApply/myApproveList',
		method: 'get',
		params
	})
}

export function leaveApplyDetail(code) {
	return request({
		url: '/leaveApply/' + code,
		method: 'get',
	})
}

/**
 * 附件上传
 * @param {Object} file
 */
// export function upload(data) {
// 	return request({
// 		url: '/common/upload',
// 		method: 'post',
// 		data,
// 		header: {
// 			'Content-Type': 'multipart/form-data'
// 		}
// 	})
// }
export function uploadImg(data) {
	return upload({
		url: '/common/upload',
		name: data.name,
		filePath: data.filePath,
		
	})
}

/**
 * 是否在打卡范围内
 * lat，lng
 */
export function isCheckInRange(data) {
	return request({
		url: '/clockRule/isCheckInRange',
		method: 'post',
		data,
	})
}

/**
 * 提交打卡
 * ruleId
 */
export function clockIn(data) {
	return request({
		url: '/clockRule/clockIn',
		method: 'post',
		data,
	})
}

/**
 * 打卡规则列表
 * @param {Object} params
 */
export function getClockRuleList(params) {
	return request({
		url: '/clockRule/list',
		method: 'get',
		params,
	})
}

/**
 * 报修申请
 * ruleId
 */
export function repairApply(data) {
	return request({
		url: '/dormRepairApply/apply',
		method: 'post',
		data,
	})
}

/**
 * 报修列表
 * ruleId
 */
export function repairList(params) {
	return request({
		url: '/dormRepairApply/myList',
		method: 'get',
		params,
	})
}

/**
 * 报修详情
 * ruleId
 */
export function repairDetail(id) {
	return request({
		url: '/dormRepairApply/'+id,
		method: 'get',
	})
}

/**
 * 报修检修
 * ruleId
 */
export function repairjx(data) {
	return request({
		url: '/dormRepairApply/service',
		method: 'post',
		data
	})
}


/**
 * 楼栋列表
 * ruleId
 */
export function buildingList(params) {
	return request({
		url: '/building/list',
		method: 'get',
		params
	})
}


/**
 * 宿舍列表
 * ruleId
 */
export function dormList(params) {
	return request({
		url: '/dorm/list',
		method: 'get',
		params
	})
}

export function getDormDetail(id) {
	return request({
		url: '/dorm/' + id,
		method: 'get'
	})
}

/**
 * 获取楼栋宿舍
 */
export function getBuildingAndDormList() {
	return request({
		url: '/dorm/buildingAndDormList',
		method: 'get'
	})
}


/**
 * 新增查寝
 */
export function addDormCheck(data) {
	return request({
		url: '/dormCheck/check',
		method: 'post',
		data,
	})
}

/**
 * 新增查寝
 */
export function queryCheckHistory(data) {
	return request({
		url: '/dormCheck/queryCheckHistory',
		method: 'post',
		data,
	})
}

/**
 * 补卡申请列表
 */
export function getCardApplyList(params) {
	return request({
		url: '/cardApply/myApproveList',
		method: 'get',
		params,
	})
}

/**
 * 新增补卡
 */
export function addcardApply(data) {
	return request({
		url: '/cardApply/launch',
		method: 'post',
		data,
	})
}

/**
 * 补卡详情
 */
export function cardApplyDetail(id) {
	return request({
		url: '/cardApply/' + id,
		method: 'get',
	})
}
